/**
 * 
 */

/*
ThinkCMF8以后，post数据必须要有下面的二个header
var headers = {'XX-Device-Type': 'web'};
var token = localStorage.getItem('token');
if (token) {
    headers['Authorization'] = token;
}
*/

export const BASEURL = "https://f.kjdll.cn:9999/api/v1"
export const url = {
    getUserZzjgList: "/zzjg/getUserZzjg",
}

axios.defaults.headers.post['Content-Type'] = 'application/json';
export const Post = (url, params) => {
    let token = localStorage.getItem('token');
    let LoginDeviceType = localStorage.getItem('LoginDeviceType');;    //thinkcmf8后台登陆逻辑里没有这个字段，只有第三方应用才有    //let LoginDeviceType = localStorage.getItem('LoginDeviceType');
    return new Promise((resolve, reject) => {
        //取得项目资料
        axios({
            method: 'post',
            url: url,
            params: params,
            responseType: 'json',
            headers: {
                'Content-Type': 'application/json',//multipart/form-data,application/json
            },
            headers: {
                'X-Requested-With': 'XMLHttpRequest',
                'XX-Device-Type': LoginDeviceType,
                'XX-Token': token,
                'Authorization': 'Bearer ' + token,
            },
        }).then(function (res) {
            if (res.data.code == 1 || res.data.code == 200) {
                resolve(res.data);
            }else{
                reject(res.data);
            }
        }).catch((res) => {
            reject(res.data);
        });
    });
}

export default {
    BASEURL, url, Post
}
